home *** CD-ROM | disk | FTP | other *** search
- Path: news.ox.ac.uk!kinder
- From: kinder@teaching.physics.ox.ac.uk (David Kinder)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: varying-length argument list
- Date: 11 Mar 96 11:03:26 GMT
- Organization: Oxford University
- Message-ID: <4i11d3$idm@news.ox.ac.uk>
- References: <549.6641T218T2207@zedat.fu-berlin.de>
- NNTP-Posting-Host: teaching1.physics.ox.ac.uk
- X-Newsreader: TIN [version 1.2 PL0]
-
- crayor (crayor@zedat.fu-berlin.de) wrote:
- : Is there any way to code it in C?
- : Using va_arg() would mean that I have to recode sprintf(), right?
-
- What you need is vsprintf(). To give an example using vprintf() (but the same
- idea):
-
- #include <stdio.h>
- #include <stdarg.h>
-
- void MyPrintf(const char *format,...);
-
- int main()
- {
- MyPrintf("Testing: %d %d %d...\n",1,2,3);
- return 0;
- }
-
- void MyPrintf(const char *format,...)
- {
- va_list ap;
-
- va_start(ap,format);
- vprintf(format,ap);
- va_end(ap);
- }
-
-
- David
-
-